﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using Bll;
using Model;
using Newtonsoft.Json;

namespace WebApiServer.Controllers
{
    public class StandController : ApiController
    {
        StandBll bll = new StandBll();
        #region 显示推荐菜（上）
        [HttpPost]
        /// <summary>
        /// 显示推荐菜（上）
        /// </summary>
        /// <returns></returns>
        public string PostShowStand()
        {
            return JsonConvert.SerializeObject(bll.ShowStand());
        }

        #endregion

        #region 查询一条数据
        [HttpPost]
        public string PostStand(int id)
        {
            List<Stand> list = bll.ShowStand();
            Stand lst = list.Where(p => p.standId == id).FirstOrDefault();
            return JsonConvert.SerializeObject(lst);
        }
        #endregion

        #region 添加推荐菜（上）
        /// <summary>
        /// 添加推荐菜（上）
        /// </summary>
        /// <param name="n"></param>
        /// <returns></returns>
        public int GetAddStand(int id)
        {
            MenuBll dll=new MenuBll();
            List<Menu> list = dll.Menushow();
            Menu lst = list.Where(x => x.MenuId == id).FirstOrDefault();
            Stand n = new Stand();
            n.standName = lst.MenuName;
            n.standPhoto = lst.MenuPhoto;
            n.standPrice = lst.MenuPrice;
            n.StandDescrib = lst.MenuDescrib;
            return bll.AddStand(n);
        }
        #endregion

        #region 删除主菜单
        /// <summary>
        /// 删除主菜单
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public int GetDelMenu(string id)
        {
            return bll.DelMenu(id);
        }
        #endregion
    }
}
